package com.dldata.devtools30.repository.devtexcel;


import com.dldata.devtools30.entity.DevtExcelEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**

 */
@Repository
public interface DevtExcelDao extends com.dldata.devtools30.repository.BaseRepository<DevtExcelEntity,String>, JpaSpecificationExecutor<DevtExcelEntity> {
        
        @Query("select t from DevtExcelEntity t order by t.xh")
        public List<DevtExcelEntity> getAllFormType();

        @Query("select t from DevtExcelEntity t where t.typeId = ?1 order by t.xh")
        public List<DevtExcelEntity> findByTypeId(String typeid);

        @Query("select t.id as id,t.name as name,t.bz as bz,t.createTime as createTime,t.xh as xh,ta.name as tableName,ta.code as tableCode,ty.name as typeName from DevtExcelEntity t   left join DevtModelMetadataTableEntity ta on ta.id=t.tableId  left join DevtExcelTypeEntity ty on t.typeId=ty.id where  t.name like ?1 order by t.xh")
        public List<Map> findNameList(String name);

        @Query("select t.id as id,t.name as name,t.bz as bz,t.createTime as createTime,t.xh as xh,ty.name as typeName ,ta.name as tableName,ta.code as tableCode from DevtExcelEntity t   left join DevtModelMetadataTableEntity ta on ta.id=t.tableId  left join DevtExcelTypeEntity ty on t.typeId=ty.id where t.typeId = ?1 and t.name like ?2   order by t.xh")
        public List<Map> findByList(String typeid, String name);

        @Query("select f from DevtExcelEntity f where f.id = ?1 order by f.xh ")
        public DevtExcelEntity getById(String id);


        @Query("select f from DevtExcelEntity f where f.xh = ?1 order by f.xh ")
        public List<DevtExcelEntity> findByXh(Integer xh);


}
